//
//  String+XYExtension.swift
//  Swift-WB
//
//  Created by lxy on 2017/6/14.
//  Copyright © 2017年 lixiya. All rights reserved.
//

import Foundation
import UIKit

extension String {
    
    func xy_size(width: CGFloat, font: UIFont) -> CGSize {
        let str = self as NSString
        let rect = str.boundingRect(with: CGSize(width: width, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
        return rect.size
    }
    
    func xy_height(width: CGFloat, font: UIFont) -> CGFloat {
        return self.xy_size(width: width, font: font).height
    }
    
    func xy_width(font: UIFont) -> CGFloat {
        return self.xy_size(width: CGFloat.greatestFiniteMagnitude, font: font).height
    }
    
}
